/*
 * main.cpp
 *
 *  Created on: Feb 2, 2009
 *      Author: Kelvin
 */
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

#include "libunzip/zip.h"

int main( int argc, char **argv)
{
	zip_fileinfo zi;
	zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour =
	zi.tmz_date.tm_mday = zi.tmz_date.tm_mon = zi.tmz_date.tm_year = 0;
	zi.dosDate = 0;
	zi.internal_fa = 0;
	zi.external_fa = 0;
	
	zipFile file = zipOpen("test.zip",APPEND_STATUS_CREATE);
	
	zipOpenNewFileInZip(file,"test.txt",&zi,NULL,0,NULL,0,NULL,Z_DEFLATED,Z_DEFAULT_COMPRESSION);
	char buff[500];
	strcpy(buff,"Hello");
	zipWriteInFileInZip(file,buff,strlen(buff)-1);
	zipCloseFileInZip(file);
	
	zipOpenNewFileInZip(file,"test/test2.txt",&zi,NULL,0,NULL,0,NULL,Z_DEFLATED,Z_DEFAULT_COMPRESSION);
	strcpy(buff,"Hello test 2");
	zipWriteInFileInZip(file,buff,strlen(buff)-1);
	zipCloseFileInZip(file);
	
	char comment[1000];
	strcpy(comment,"archive comment");
	zipClose(file,comment);
	
	cin.get();
	return 0;
}
